import org.junit.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Random;

public class TestGC {
    
    public static void main(String[] args) throws Exception {
        List<Object> list = new ArrayList<Object>();
        while (true) {
            int sleep = new Random().nextInt(100);
            if (System.currentTimeMillis() % 2 == 0) {
                list.clear();
            } else {
                for (int i = 0; i < 10000; i++) {
                    Properties properties = new Properties();
                    properties.put("key_" + i, "value_" + System.currentTimeMillis() + i);
                    list.add(properties);
                }
            }
            
            System.out.println("list大小为：" + list.size());
            
            Thread.sleep(sleep);
        }
    }
    
    @Test
    public void testAAA() {
        
        int[] prices = {3, 2, 6, 5, 0, 3};
        
        int len = prices.length;
        
        long start = System.nanoTime();
        for (int i = 0; i < 10000000; i++) {
            for (int j = 0; j < len; j++) {
                int a = prices[j];
            }
        }
        System.out.println(System.nanoTime() - start);
        
        long start1 = System.nanoTime();
        for (int i = 0; i < 10000000; i++) {
            for (int j = 0; j < prices.length; j++) {
                int a = prices[j];
            }
        }
        System.out.println(System.nanoTime() - start1);
        // Deque
        // Stack
    }
    
    @Test
    public void testClassLoader() {
        // ClassLoader
        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
        System.out.println(classLoader);
        ClassLoader platformClassLoader = classLoader.getParent();
        System.out.println(platformClassLoader);
        System.out.println(platformClassLoader.getParent());
    }
}
